<template>
  <view class="points-page">
    <!-- 顶部points信息区域 -->
    <view class="top-bar">
      <view class="points-info">
        <text class="points-number">我的points</text>
        <text class="points-count">15</text>
        <text class="detail-btn" @click="goDetail">points明细</text>
      </view>
      
    </view>

    <!-- 兑换商品列表区域 -->
    <view class="exchange-list">
      <view class="goods-item" v-for="(item, index) in goodsList" :key="index">
        <image :src="item.img" class="goods-img"></image>
        <text class="goods-name">{{item.name}}</text>
        <text class="score-need">
          <text class="score-icon">●</text>{{item.score}}points
        </text>
        <button class="exchange-btn" :disabled="item.disabled">{{item.btnText}}</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      goodsList: [
        {
          img: "/static/pointsMall/Sunglasses.png", // 实际替换成项目中图片路径
          name: "恒墨镜",
          score: 1,
          btnText: "立即兑换",
          disabled: false
        },
        {
          img: "/static/pointsMall/pike.png",
          name: "匹克乔丹鞋",
          score: 1,
          btnText: "立即兑换",
          disabled: false
        },
        {
          img: "/static/goods3.png",
          name: "000",
          score: 100,
          btnText: "立即兑换",
          disabled: false,
          extraText: "+100元" // 演示有额外费用的情况，可根据需求控制显示
        },
        {
          img: "/static/goods4.png",
          name: "hi",
          score: 10,
          btnText: "立即兑换",
          disabled: false
        }
      ]
    };
  },
  methods: {
    goDetail() {
      // 点击points明细的跳转逻辑，实际可跳转到对应明细页面
      uni.navigateTo({
        url: "/pages/detail/detail" 
      });
    }
  }
};
</script>

<style lang="scss">
.points-page {
  padding: 10px;
  background-color: #fff;

  .top-bar {
	  background: url('/static/pointsMall/top.png') no-repeat center/cover; 
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;

    border-radius: 10px;
    color: #fff;

    .points-info {
      display: flex;
      flex-direction: column;

      .points-number {
        font-size: 14px;
        margin-bottom: 5px;
      }

      .points-count {
        font-size: 20px;
        font-weight: bold;
      }

      .detail-btn {
        font-size: 12px;
        color: #fff;
        border: 1px solid #fff;
        border-radius: 5px;
        padding: 2px 8px;
        align-self: flex-start;
        margin-top: 5px;
      }
    }

    .gift-box {
      width: 100px;

      image {
        width: 100%;
		height: 60rpx;
      }
    }
  }

  .exchange-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 10px;
	box-sizing: border-box;
	width: 100%;

    .goods-item {
      width: calc(50% - 5px);
      background-color: #fff;
      border-radius: 8px;
      box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
	  box-sizing: border-box;
      margin-bottom: 10px;
      padding: 5px;
      display: flex;
      flex-direction: column;
      align-items: center;

      .goods-img {
        width: 100%;
        height: 140px;
        border-radius: 8px;
        margin-bottom: 4px;
      }

      .goods-name {
        font-size: 14px;
        margin-bottom: 2px;
        text-align: center;
      }

      .score-need {
        font-size: 12px;
        color: #f9bb2d;
        display: flex;
        align-items: center;
        margin-bottom: 8px;

        .score-icon {
          font-size: 16px;
          margin-right: 2px;
        }
      }

      .exchange-btn {
        width: 120px;
        background-color: #ff3b30;
        color: #fff;
        font-size: 14px;
        border-radius: 20px;
      }
    }
  }
}
</style>
